{extend name="Layout/index" /}

{block name="main"}
<div style="margin: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加角色</legend>
    </fieldset>

    <form class="layui-form " action="{:url('role/store')}" method="POST">
        <div class="layui-form-item">
            <label class="layui-form-label">名字</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <input type="text" name="description" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">新增</button>
                <a href="{:url('role/index')}" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>
{/block}

{block name="footer"}
<script>
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form;

        //自定义验证规则
        form.verify({
            title: function(value) {
                if(value.length < 1) {
                    return '角色名不能为空角色名不能为空';
                }
            }
        });
    });
</script>
{/block}